package com.yutel.multher.jas.comm;

import java.io.File;
import java.io.FileFilter;

public class ExtensionFileFilter implements FileFilter {

	private String extension;

	public ExtensionFileFilter(String extension) {
		this.extension = extension;
	}

	@Override
	public boolean accept(File pathname) {
		if (pathname.isDirectory()) {
			return false;
		}
		String name = pathname.getName();
		int idx = name.lastIndexOf(".");
		if (idx == -1) {
			return false;
		} else if (idx == name.length() - 1) {
			return false;
		} else {
			return extension.equals(name.substring(idx + 1));
		}
	}
}
